<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子26-JS进阶（二）</title>
    </head>

    <body>
        <pre>
            <code>
                    // 例子26

                    var Person = function(name, age) {
                        this.name = name;
                        this.age = age;
                        this.getName = function() {
                            return this.name;
                        }
                    }

                    var Tom = new Person('Tom', 20);
                    var Jerry = new Person('Jerry', 22);
                    console.log(Tom.getName());  // Tom
                    console.log(Tom instanceof Person); // true
                    console.log(Jerry.getName());  // Jerry
                    console.log(Jerry instanceof Person); // true
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/26.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>